///**
// * Created by 冠东 on 2017/11/13.
// */
//var tabs=[
//    {url:"index",text:"首页",id:"index-tab",closeable:0}
//];
//
//mainApp.controller("tabController",function($scope,$state){
//    $scope.tabs=tabs;
//    $scope.closeable=function($index){
//        console.log($scope.tabs);
//        console.log("要删除的是"+$index);
//        tabs.splice($index,1);
//        $scope.tabs.splice($index,1);
//
//        var t="" +tabs[$index-1].url;
//
//        console.log($scope.tabs[$index-1].url);
//        console.log(t);
//        console.log("index");
//        console.log($scope.tabs);
//        $state.go("index");
//
//    }
//})


/**
 * Created by 冠东 on 2017/11/13.
 */

mainApp.controller("tabController",function($scope,overallSituationService,$state){

    $scope.tabs=[
        {url:"index",text:"首页",id:"index-tab",closeable:0}
    ]
    $scope.$on('addTab', function(event, data){
        clickTab(data,$scope.tabs);
    })


    $scope.createTab=function($event){
        overallSituationService.loginIntercept();
        var tab={url:$event.currentTarget.id,text:$event.currentTarget.innerText,id:$event.currentTarget.id+"-tab",closeable:1};
        clickTab(tab,$scope.tabs);
    }
    $scope.switchTabActive=function($event){
        switchModule($event.target.parentNode.id);
    }
    $scope.closeable=function($index){
        $scope.tabs.splice($index,1);
        var length=0+$scope.tabs.length;
        var t=""+$scope.tabs[length-1].url;

        switchModule($scope.tabs[length-1].id);
        $state.go(t);

    }
})


